﻿using Common.Lib.Dto;
using Common.Lib.Parameter;
using Common.Lib.Service;
using Microsoft.AspNetCore.Mvc;
using Server.Todo.Service;

namespace Server.Todo.Controllers
{
    /// <summary>
    /// 登录
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class LoginController : ControllerBase
    {
        private readonly ILoginService loginService;

        /// <summary>
        /// 登录
        /// </summary>
        public LoginController(ILoginService loginService)
        {
            this.loginService = loginService;
        }

        [HttpPost]
        public async Task<ApiResponse> Register([FromBody] UserDto model)
        {
            return await loginService.RegisterAsync(model);
        }


        [HttpGet]
        public async Task<ApiResponse> Login(string account,string password)
        {
            return await loginService.LoginAsync(account,password);
        }

    }
}
